//
// Created by power on 2021/12/9.
//

#include "RPCCLient.h"


int main() {
    std::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
    std::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
    std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
    SQLServiceClient client(protocol);

    try {
        transport->open();
        string result = "";
        string sql = "select * from server_meta where nodeindex = 1";


        try {
            client.select(result,sql);
            cout << "Whoa? We can divide by zero!" << endl;
        } catch (TException & io) {
            cout << "InvalidOperation: " << io.what() << endl;
            // or using generated operator<<: cout << io << endl;
            // or by using std::exception native method what(): cout << io.what() << endl;
        }

        cout << "Received log: " << result << endl;
        transport->close();
    } catch (TException& tx) {
        cout << "ERROR: " << tx.what() << endl;
    }
}